package es.ats.codington.festival.utils;

import es.ats.codington.festival.json.JsonTrial;
/**
 * 
 * @author Codington_RED
 *
 */
public class FERSDbQuery {

	//Event 
	
	
	
	private static String allEvents = "SELECT eventId, name, description, place, startEvent, endEvent, dayEvent, eventType, seatsAvailable, idPlace FROM event;";  
	private static String searchByEventName = "SELECT eventId, name, description, place, startEvent, endEvent, dayEvent, eventType, seatsAvailable, idPlace FROM event WHERE name = ?;";
	private static String getEvent = "SELECT eventId, name, description, place, startEvent, endEvent, dayEvent, eventType, seatsAvailable, idPlace FROM event WHERE eventId = ?;";
	private static String updateEvent = "UPDATE event SET name = ?, description = ?, place = ?, startEvent = ?, endEvent = ?, dayEvent = ?, eventType = ?, seatsAvailable = ?, idPlace = ? WHERE eventId = ?;";
	private static String insertEvent = "INSERT INTO event (name, description, place, startEvent, endEvent, dayEvent, eventType, seatsAvailable, idPlace) values(?, ?, ?, ?, ?, ?, ?, ?, ?);";
	private static String updateSeatsEventInc = "UPDATE event SET seatsAvailable = seatsAvailable + 1 WHERE eventId = ?;";
	private static String updateSeatsEventDec = "UPDATE event SET seatsAvailable = seatsAvailable - 1 WHERE eventId = ?;";
	private static String idEvent = "SELECT eventId FROM event WHERE name = ? and startEvent = ?;";
	

	 /**
	  * method which calls idEvent SQL query
	  * @return idEvent
	  */
	 public static String getIdEvent(){
		 return idEvent;
	 }
	
	/**
	 * method which calls allEvents SQL query
	 * @return allEvents
	 */
	 public static String getAllEvents(){
		 return allEvents;
	 }
	 
	 /**
	  * method which calls searchByEventName SQL query
	  * @return searchByEventName
	  */
	 public static String getSearchByEventName(){
		 return searchByEventName;
	 }
	 
	 /**
	  * method which calls getEvent SQL query
	  * @return getEvent
	  */
	 public static String getGetEvent(){
		 return getEvent;
	 }
	 /**
	  * method which calls updateEvent SQL query
	  * @return updateEvent
	  */
	 public static String getUpdateEvent(){
		 return updateEvent;
	 }
	 /**
	  * method which calls insertEvent SQL query
	  * @return insertEvent
	  */
	 public static String getInsertEvent(){
		 return insertEvent;
	 }
	 /**
	  * method which calls updateSeatsEventInc SQL query
	  * @return updateSeatsEventInc
	  */
	 public static String getUpdateSeatsEventInc(){
		 return updateSeatsEventInc;
	 }
	 /**
	  * method which calls updateSeatsEventDec SQL query
	  * @return updateSeatsEventDec
	  */
	 public static String getUpdateSeatsEventDec(){
		 return updateSeatsEventDec;
	 }
	 
	 //People-visitor
	 
	
	 private static String insertPeople = "INSERT INTO people (firstName, lastName, dni, email, phoneNumber, address) values(?, ?, ?, ?, ?, ?);";
	 private static String insertVisitor = "INSERT INTO visitor (idVisitor, userName, password, admin) values(?,?,?,?);";
	 private static String searchVisitor = "SELECT idVisitor, userName, password, admin FROM visitor WHERE idVisitor = ?;";
	 private static String searchPeople = "SELECT idPeople, firstName, lastName, dni, email, phoneNumber, address FROM people WHERE idPeople = ?;";
	 private static String updatePeople =  "UPDATE people SET firstName = ?, lastName = ?, dni = ?, email = ?, phoneNumber = ?, address = ? WHERE idPeople = ?;";
	 private static String updateVisitor = "UPDATE visitor SET userName = ?, password = ?, admin = ? WHERE idVisitor = ?;";
	 private static String changePasswordVisitor = "UPDATE visitor SET password = ? WHERE userName = ?;";
	 private static String checkEvent = "SELECT id, idEvent, idVisitor FROM eventsignup WHERE idEvent = ? AND idVisitor = ?;";
	 private static String unRegisterVisitorToEvent = "DELETE FROM eventsignup WHERE idEvent = ? AND idVisitor = ?;";
	 private static String registerVisitorToEvent = "INSERT INTO eventsignup (idEvent, idVisitor) values(?, ?);";
	 private static String eventsRegistered = "SELECT eventId, name, description, place, startEvent, endEvent, dayEvent, eventType, seatsAvailable, idPlace FROM event WHERE eventId IN (SELECT idEvent FROM eventsignup WHERE idVisitor = ?);";
	 private static String checkLogin = "SELECT idVisitor FROM visitor WHERE userName = ? AND password = ?;";
	 private static String checkPeople = "SELECT idPeople FROM people WHERE dni = ?;";
	 private static String checkAdmin = "SELECT admin FROM visitor WHERE userName = ? AND password = ?;";
	 private static String updatePeopleDni = "UPDATE people SET firstName = ?, lastName = ?, dni = ?, email = ?, phoneNumber = ?, address = ? WHERE dni = ?;";
	 
	 /**
	  * method which calls updatePeopleDni SQL query
	  * @return updatePeopleDni
	  */
	 public static String getUpdatePeopleDni() {
		 return updatePeopleDni;
	 }
	 
	 /**
	  * method which calls insertPlace SQL query
	  * @return insertPeople
	  */
	 public static String getInsertPeople() {
	   return insertPeople;
	 }
	 
	 /**
	  * method which calls checkPeople SQL query
	  * @return checkPeople
	  */
	 public static String getCheckPeople() {
		 return checkPeople;
	 }
	 
	 /**
	  * method which calls insertVisitor SQL query
	  * @return insertVisitor
	  */
	 public static String getInsertVisitor() {
		 return insertVisitor;
	 }
	 
	 /**
	  * method which calls searchVisitor SQL query
	  * @return searchVisitor
	  */
	 public static String getSearchVisitor() {
		 return searchVisitor;
	 }
	 
	 /**
	  * method which calls searchPeople SQL query
	  * @return searchPeople
	  */
	 public static String getSearchPeople() {
		 return searchPeople;
	 }
	 
	 /**
	  * method which calls updateVisitor SQL query
	  * @return updateVisitor
	  */
	 public static String getUpdateVisitor() { 
		 return updateVisitor;
	 }
	 
	 /**
	  * method which calls checkLogin SQL query
	  * @return checkLogin
	  */
	 public static String getCheckLogin() {	
		return checkLogin;
	 }
	 
	 /**
	  * method which calls checkAdmin SQL query
	  * @return checkAdmin
	  */
	 public static String getCheckAdmin() { 
		 return checkAdmin;
	 }
	 
	 /**
	  * method which calls updatePeople SQL query
	  * @return updatePeople
	  */
	 public static String getUpdatePeople() {
		 
		 return updatePeople;
	 }
	 
	 /**
	  * method which calls changePasswordVisitor SQL query
	  * @return changePasswordVisitor
	  */
	 public static String getChangePasswordVisitor() {
		 
		 return changePasswordVisitor;
	 }
	 
	 /**
	  * method which calls checkEvent SQL query
	  * @return checkEvent
	  */
	 public static String getCheckEvent() {
		 return checkEvent;
	 }
	 
	 /**
	  * method which calls unRegisteredVisitorToEventSQL query
	  * @return unRegisterVisitorToEvent
	  */
	 public static String getUnRegisterVisitorToEvent() {
		 return unRegisterVisitorToEvent;
	 }
	 
	 /**
	  * method which calls registeredVisitorToEvent SQL query
	  * @return registerVisitorToEvent
	  */
	 public static String getRegisterVisitorToEvent() {
		 return registerVisitorToEvent;
	 }
	
	 /**
	  * method which calls eventsRegistered SQL query
	  * @return eventsRegistered
	  */
	 public static String getEventsRegistered() {
		 return eventsRegistered;
	 }
	 
	 /**
	  * Place
	  */
	 
	 
	 public static String insertPlace = "INSERT INTO place (namePlace, capacityPlace, placeDescription, zonePlace, imagePlace) values(?, ?, ?, ?, ?);";
	 public static String allPlaces = "SELECT idPlace, namePlace, capacityPlace, placeDescription, zonePlace, imagePlace FROM place;";
	 public static String updatePlace = "UPDATE place SET namePlace = ?, capacityPlace = ?, placeDescription = ?, zonePlace = ?, imagePlace = ? WHERE idPlace = ?;";
	 
	 /**
	  * method which calls insertPlace SQL query
	  * @return insertPlace
	  */
	 public static String getInsertPlace() {
		 return insertPlace;
	 }
	 
	 /**
	  * method which calls getAllPlaces SQL query
	  * @return allPlaces
	  */
	 public static String getAllPlaces(){
		 return allPlaces;
	 }
	 
	 /**
	  * method which calls updatePlace SQL query
	  * @return updatePlace
	  */
	 public static String getUpdatePlace() {
		 return updatePlace;
	 }

	 
 

}
